$(function(){
	var supplyName; 
	var lawer;
	if(null != localStorage.getItem("supplyName")){
		supplyName = localStorage.getItem("supplyName");
	}
	if(null != localStorage.getItem("lawer")){
		lawer = localStorage.getItem("lawer");
	}
	if(supplyName!=undefined){
		if($('#lawerName').length>0){
			$('#lawerName').remove();
		}
		var s = '<input type="text" class="amend" name="supplyName" id="supply" value=""/>';
		$(document.body).append(s);
		//console.log($('#supply').length);
		//$("#supply").val(supplyName);
		$("#supply").attr("value",supplyName);
		//alert($("#supply").val());
		//localStorage.removeItem("supplyName");
		$(".btn").bind('click',function(){
			updateSupply();
			window.location.href="getSupply.do";
		});
	}
	if(lawer!=undefined){
		if($('#supply').length>0){
			$('#supply').remove();
		}
		var s = '<input type="text" class="amend" name="lawer" id="lawerName" value=""/>';
		$(document.body).append(s);
		$("#lawerName").val(lawer);
		//localStorage.removeItem("lawer");
		$(".btn").bind('click',function(){
			updateLawer();
			window.location.href="getSupply.do";
		});
	}

});
function updateSupply(){
	var supplyName = $("#supply").val();
	var supplyId = localStorage.getItem("supplyId");
		$.ajax({
			type:"POST",
			data:{supplyName:supplyName,supplyId:supplyId},
			url : server_url+'rest/supply/supplyEdit.do?ran='+Math.random(),
			success:function(data){
				if(data.retCode == "0000"){
					easyAlert("操作成功");
				}else{
				easyAlert("网络异常,请稍后再试");
				}
			},
		});
		
		
}
function updateLawer(){
	var lawer = $("#lawerName").val();
	var supplyId = localStorage.getItem("supplyId");
		$.ajax({
			type:"POST",
			data:{lawer:lawer,supplyId:supplyId},
			url : server_url+'rest/supply/supplyEdit.do?ran='+Math.random(),
			success:function(data){
				if(data.retCode == "0000"){
					easyAlert("操作成功");
				}else{
				easyAlert("网络异常,请稍后再试");
				}
			},
		});
		
		
}

function backing(){
	window.location=server_url+"getSupply.do";
}
